using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter12
{
	/// <summary>
	/// Example01: The Seesaw Revisited
	/// A seesaw consisting of a uniform board of 
	/// mass M and length l supports a father and daughter 
	/// with masses m_f and m_d, respectively, as shown in 
	/// Figure 12.8. the support (called the fulcrum) is 
	/// under the center of gravity of the board, the father 
	/// is a distance d from the center, and the daughter is 
	/// a distance l/2 from the center.
	/// (A) Determine the magnitude of the upward force n 
	/// exerted by the support on the board.
	/// n = m_f g + m_d g + Mg
	/// (B) Determine where the father should sit to balance 
	/// the system.
	/// d = m_d / m_f * 1/2 * l
	/// </summary>
	public class Example01
	{
		public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			double mf = 80.0, md = 30.0, mb = 100.0, l = 2.0;
			L.Force[] f = new L.Force[4];
			L.Position[] r = new L.Position[4];
			f[1] = new L.Force();
			f[1].Y = -mf*L.Constant.AccelerationOfGravity;
			f[2] = new L.Force();
			f[2].Y = -md*L.Constant.AccelerationOfGravity;
			f[3] = new L.Force();
			f[3].Y = -mb*L.Constant.AccelerationOfGravity;
			f[0] = new L.Force();
			f[0].YVariableQ = true;
			r[1] = new L.Position();
			r[1].XVariableQ = true;
			r[2] = new L.Position();
			r[2].X = - l/2.0;
			r[3] = new L.Position();
			r[0] = new L.Position();

			L.RigidBody board = new L.RigidBody();
			board.SolveStaticEquilibrium(r,f);
			
			result+=Convert.ToString(f[0].Y)+"\r\n";
			result+=Convert.ToString((mf  + md  + mb)*L.Constant.AccelerationOfGravity)+"\r\n";
			result+=Convert.ToString(r[1].X)+"\r\n";
			result+=Convert.ToString(md / mf * 1.0/2.0 * l)+"\r\n";
		}
	}
}
